package cn.dengta.webapp.user.dto;

import java.util.Map;

import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.user.entity.ActPlanetExploreLog;
import cn.dengta.webapp.user.model.PlanetExploreType;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.StringUtil;
import me.codeplayer.util.X;

@Getter
@Setter
public class ActPlanetExploreLogDTO extends AbstractVO<ActPlanetExploreLog> {

	/** 金星 */
	Integer planet;
	/** 金星押注数 */
	Integer betCount;
	/** 金星钻石数 */
	Integer coin;
	/** 木星 */
	Integer planet1;
	/** 木星押注数 */
	Integer betCount1;
	/** 木星钻石数 */
	Integer coin1;
	/** 水星 */
	Integer planet2;
	/** 水星押注数 */
	Integer betCount2;
	/** 水星钻石数 */
	Integer coin2;
	/** 火星 */
	Integer planet3;
	/** 火星押注数 */
	Integer betCount3;
	/** 火星钻石数 */
	Integer coin3;
	/** 土星 */
	Integer planet4;
	/** 土星押注数 */
	Integer betCount4;
	/** 土星钻石数 */
	Integer coin4;
	/** 天王星 */
	Integer planet5;
	/** 天王星押注数 */
	Integer betCount5;
	/** 天王星钻石数 */
	Integer coin5;
	/** 海王星 */
	Integer planet6;
	/** 海王押注数 */
	Integer betCount6;
	/** 海王钻石数 */
	Integer coin6;
	/** 开普勒星 */
	Integer planet7;
	/** 开普勒星押注数 */
	Integer betCount7;
	/** 开普勒星钻石数 */
	Integer coin7;
	/** 中奖钻石数 */
	Integer prizeCoin;
	/** 中奖星球 */
	Integer prizePlanet;
	/** 状态：-1=未参与；0=探险失败；1=探险成功 */
	Integer status;
	String remark;
	Map<String, Object> user;
	Integer userCount;
	String prizePlanet_;

	public ActPlanetExploreLogDTO init(ActPlanetExploreLog log, Map<Integer, Integer> entries) {
		if (X.isValid(entries)) {
			Integer value = PlanetExploreType.VENUS.value;
			this.coin = entries.get(value);
			if (coin != null) {
				this.planet = value;
				this.betCount = X.mapElse(log, ActPlanetExploreLog::getBetCount, 0);
			}
			this.coin1 = entries.get(value = PlanetExploreType.JUPITER.value);
			if (coin1 != null) {
				this.planet1 = value;
				this.betCount1 = X.mapElse(log, ActPlanetExploreLog::getBetCount1, 0);
			}
			this.coin2 = entries.get(value = PlanetExploreType.MERCURY.value);
			if (coin2 != null) {
				this.planet2 = value;
				this.betCount2 = X.mapElse(log, ActPlanetExploreLog::getBetCount2, 0);
			}
			this.coin3 = entries.get(value = PlanetExploreType.MARS.value);
			if (coin3 != null) {
				this.planet3 = value;
				this.betCount3 = X.mapElse(log, ActPlanetExploreLog::getBetCount3, 0);
			}
			this.coin4 = entries.get(value = PlanetExploreType.SATURN.value);
			if (coin4 != null) {
				this.planet4 = value;
				this.betCount4 = X.mapElse(log, ActPlanetExploreLog::getBetCount4, 0);
			}
			this.coin5 = entries.get(value = PlanetExploreType.URANUS.value);
			if (coin5 != null) {
				this.planet5 = value;
				this.betCount5 = X.mapElse(log, ActPlanetExploreLog::getBetCount5, 0);
			}
			this.coin6 = entries.get(value = PlanetExploreType.NEPTUNE.value);
			if (coin6 != null) {
				this.planet6 = value;
				this.betCount6 = X.mapElse(log, ActPlanetExploreLog::getBetCount6, 0);
			}
			this.coin7 = entries.get(value = PlanetExploreType.KEPLER.value);
			if (coin7 != null) {
				this.planet7 = value;
				this.betCount7 = X.mapElse(log, ActPlanetExploreLog::getBetCount7, 0);
			}
		}
		return this;
	}

	public String getAddTime_() {
		return super.getAddTime_();
	}

	public String getPlanet_() {
		return X.map(PlanetExploreType.of(planet), PlanetExploreType::defaultLabel);
	}

	public String getPlanet1_() {
		return X.map(PlanetExploreType.of(planet1), PlanetExploreType::defaultLabel);
	}

	public String getPlanet2_() {
		return X.map(PlanetExploreType.of(planet2), PlanetExploreType::defaultLabel);
	}

	public String getPlanet3_() {
		return X.map(PlanetExploreType.of(planet3), PlanetExploreType::defaultLabel);
	}

	public String getPlanet4_() {
		return X.map(PlanetExploreType.of(planet4), PlanetExploreType::defaultLabel);
	}

	public String getPlanet5_() {
		return X.map(PlanetExploreType.of(planet5), PlanetExploreType::defaultLabel);
	}

	public String getPlanet6_() {
		return X.map(PlanetExploreType.of(planet6), PlanetExploreType::defaultLabel);
	}

	public String getPlanet7_() {
		return X.map(PlanetExploreType.of(planet7), PlanetExploreType::defaultLabel);
	}

	public String getPrizePlanet_() {
		return StringUtil.notEmpty(prizePlanet_) ? prizePlanet_ : X.map(PlanetExploreType.of(prizePlanet), PlanetExploreType::defaultLabel);
	}

}
